import type { Factions } from '@/coreModel/types'
import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useFleetFightViewStore = defineStore('fleetFightView', () => {
  const selectedShip = ref<{ id: string; factions: Factions } | null>(null) // 因为双方舰队中，可能拥有相同型号舰船，所以需要进行区分
  const setselectedShip = (id: string, factions: Factions) => {
    selectedShip.value = { id: id, factions: factions }
  }
  // 计算 “当前传入的数据是否是当前选中的那个舰船型号”（用于计算是否高亮展示）
  const calculateIsSelectedShipModel = (id: string, factions: Factions) => {
    if (selectedShip.value?.id == id && selectedShip.value.factions == factions) {
      return true
    }
    return false
  }
  return { selectedShip, setselectedShip, calculateIsSelectedShipModel }
})
